package br.com.os2.pacemark.connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Daniel
 * 
 */

public class ConnectionFactory {

    public static final String url = "jdbc:postgresql://localhost:5432/pacemark";
    public static final String usuario = "postgres";
    public static final String senha = "123456";
    
    static{
        
        try {
            
            Class.forName("org.postgresql.Driver");
            
        } catch (ClassNotFoundException ex) {
            
            System.err.println("ERRO AO CARREGAR DRIVER DO BANCO");
            
        }
        
    }
    
    public static Connection getConnection(){
        
        Connection connection = null;
        
        try {
            
            connection = DriverManager.getConnection(url, usuario, senha);
            
        } catch (SQLException ex) {
            
            System.err.println("ERRO AO CONECTAR A BASE DE DADOS");
            
        }
        
        return connection;
        
    }
    
}
